﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace ZSZ.AdminWeb.App_Start
{
    public class ModelStateConsole
    {
        public static string GetErrorMsg(ModelStateDictionary pairs) {
            StringBuilder sb = new StringBuilder();
            foreach (var item in pairs.Keys)
            {
                if (pairs[item].Errors.Count<1)
                {
                    continue;
                }
                sb.Append(item).Append("发生错误：").AppendLine();
                foreach (var err in pairs[item].Errors)
                {
                    sb.Append(err.ErrorMessage);
                }
                sb.AppendLine();
            }
            return sb.ToString();
        }
    }
}